package com.lsa.letcode.the35.searchInsertPos;

public class Solution {
    public int searchInsert(int[] arr, int t) {
    	int i = 0;
    	int j = arr.length - 1;
    	int mid = 0;
        while(i <= j) {
        	mid = (i + j) >>> 1;
        	if (arr[mid] == t) {
        		return mid;
        	}
        	else if (arr[mid] < t) {
        		i = mid + 1;
        	}
        	else {
        		j = mid - 1;
        	}
        }
        return i;
    }
}